<template>
    <h2 style="text-align: center">{{ page === 'member' ? '电子会员卡管理' : '微信公众号管理' }}</h2>
    <div class="container">
        <el-image style="width: 1000px; height: 600px" :src="imagePage" fit="contain"></el-image>
        <el-upload ref="upload" drag :action="'api/admin/oneImage/' + page" :on-success="flush" style="margin-top: 20px">
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处<em>上传</em>，或<em>点击上传</em>，只支持JPG文件</div>
        </el-upload>
    </div>
</template>

<script setup>
import { ref, defineProps } from 'vue'

import { ElMessage } from 'element-plus'

const props = defineProps({
    page: {
        type: String,
        default: 'member',
    },
})
const upload = ref(null)
const imagePage = ref(props.page + '.jpg')

const flush = () => {
    upload.value.clearFiles()
    imagePage.value = `${props.page}.jpg?${Date.now()}`
    ElMessage.success('上传成功')
}
</script>

<style scoped>
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
}
</style>
